 //********************************************************
 // PP85.java                 Author:20172323wyh
 //
 // 输入一组整数，计算他们的均值及标准方差。
 //********************************************************
 
 import java.util.Scanner;

 public class PP85
 {
    public static void main(String[] args)
    {
      Scanner scan1 = new Scanner(System.in);
      Scanner scan2 = new Scanner(System.in);
      int[] list = new int[50];
      String another = "y";
      int index = 0, sum = 0;
      double total = 0;

      while (another.equalsIgnoreCase("y"))
      {
         System.out.println("Enter the number: ");
         int number = scan1.nextInt();      
         list[index] = number;
         index++;
 
         System.out.println();
         System.out.println("Input another number (y/n)?");
         another = scan2.nextLine();
      }
      int length = index;

      index = 0; 
      do
      { 
         sum += list[index];
         index++;
      }
      while (index <= length);
  
      double mean = sum/length;
     
      index = 0; 
      do
      {  
         double x =(list[index] - mean);
         total += Math.pow(x, 2);
         index++;
      }
      while (index < length);

      double sd = Math.sqrt(total);
    
      System.out.println();
      System.out.println("Total = " + sum + "\nMean = " + mean + "\nsd = " + sd);
    }
 }
